package com.bw.Mq;

import com.bw.domain.Message;
import com.bw.service.SendService;
import com.bw.service.SmsService;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.retry.annotation.EnableRetry;
import org.springframework.retry.annotation.Retryable;
import org.springframework.stereotype.Component;

@Component
@Slf4j
@RocketMQMessageListener(consumerGroup = "adsads",topic = "Mymesage",consumeThreadMax = 80)
public class ConsumerMq  implements RocketMQListener<Message> {
@Autowired
    SmsService smsService;

    @Override
    public void onMessage(Message message) {
        log.info("消费者接收到了消息{}",message);
        try {
            smsService.smsend(message);
            log.info("消费者发送成功{}{}",message);
        } catch (Exception e) {
            log.info("消费者发送消息异常{}{}",message,e);
        }
    }
}
